package com.watson.voice.controller;

import com.watson.voice.util.VoiceAnnouncement;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

import java.net.URLDecoder;

/**
 * @Description: 根据页面传来的文字信息进行调用语音播报的工具类方法
 * @Author watson
 * @Date 2022/7/22 16:14
 * @Version 1.0
 */
@Controller
@RequestMapping(value="/voice")
public class VoiceAnnouncementController{

    @GetMapping(value="Announcement",produces={"application/json;charset-UTF-8"})
    @ResponseBody
    public void voice(HttpServletRequest request,@RequestParam String text) throws Exception{
        try{
            text = URLDecoder.decode(text,"utf-8");
        }catch(Exception e){
            e.printStackTrace();
        }
        System.out.println("语音播放内容为："+text);
        VoiceAnnouncement.strat(text,-1);
    }
}
